package mspbots.next.ticket.core;

import lombok.RequiredArgsConstructor;
import mspbots.next.ticket.core.points.PointTicketRegistration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.ParallelFlux;
import reactor.core.scheduler.Schedulers;

import javax.validation.Valid;
import java.time.Duration;

/**
 * mspbots.next.ticket.core.AppController
 *
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 * @date Created by 2020/12/1
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("next-ticket/{tenantId}")
public class AppController {

    private final AppServiceImpl appService;

    @GetMapping("grading")
    public Flux<PointTicketRegistration> grading(@PathVariable Long tenantId, @Valid GradingRequest request) {
        return this.appService.grading(tenantId, request)
                .cache(Duration.ofMinutes(10));
    }


}
